VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsEmployers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Public Function GetEmpID(ByVal sUserName, ByVal nPAYERefNo, nComID)
    
    Dim cnGetEmpID As ADODB.Connection
    Dim rsGetEmpID As ADODB.recordSet
    Dim cmd
    
    
    Set cnGetEmpID = New ADODB.Connection
    
    Set cmd = New ADODB.Command
    Set rsGetEmpID = New ADODB.recordSet
    
    
    With cnGetEmpID
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With

    Set cmd = New ADODB.Command
    Set cmd.ActiveConnection = cnGetEmpID
    
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "dir_get_employer_details"
  
    cmd.Parameters.Append cmd.CreateParameter("Username", adVarChar, adParamInput, 10, sUserName)
    cmd.Parameters.Append cmd.CreateParameter("@PAYE_ref_no", adDouble, adParamInput, , CDbl(Val(nPAYERefNo)))
    cmd.Parameters.Append cmd.CreateParameter("@comp_alloc_number", adDouble, adParamInput, , CDbl(Val(nComID)))
    
    ' Perform the query
    Set rsGetEmpID = cmd.Execute
        
    If Not rsGetEmpID.EOF Then
        GetEmpID = rsGetEmpID("nEmpID")
    Else
        GetEmpID = ""
    End If

    'clean up
    rsGetEmpID.Close
    Set rsGetEmpID = Nothing
    cnGetEmpID.Close
    Set cnGetEmpID = Nothing
End Function



Public Function GetEmpIDRS(ByVal sUserName, ByVal nPAYERefNo, nComID) As recordSet

On Error GoTo PROC_ERROR

    Dim cnConnection As ADODB.Connection
    Dim rsRecordSet As ADODB.recordSet
    
    
    Dim cmd As ADODB.Command
    
    
    
    Set cnConnection = New ADODB.Connection
    
    With cnConnection
        .CursorLocation = adUseClient
        .IsolationLevel = adXactBrowse
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    Set rsRecordSet = New ADODB.recordSet
    With rsRecordSet
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
    End With
    
    'Johann (20071107): Removed this, as the stored proc doesn't exist. there's no trail in VSS of who did it.
'    If nComID = 3 Then
'        Set cmd = New ADODB.Command
'        cmd.CommandText = "dir_get_employer_details_INDV"
'        cmd.CommandType = adCmdStoredProc
'        cmd.ActiveConnection = cnConnection
'        cmd.Parameters.Append cmd.CreateParameter("Username", adVarChar, adParamInput, 10, sUserName)
'        cmd.Parameters.Append cmd.CreateParameter("@PAYE_ref_no", adDouble, adParamInput, , CDbl(Val(nPAYERefNo)))
'        cmd.Parameters.Append cmd.CreateParameter("@comp_alloc_number", adDouble, adParamInput, , CDbl(Val(nComID)))
'    Else
        Set cmd = New ADODB.Command
        cmd.CommandText = "dir_get_employer_details"
        cmd.CommandType = adCmdStoredProc
        cmd.ActiveConnection = cnConnection
        cmd.Parameters.Append cmd.CreateParameter("Username", adVarChar, adParamInput, 10, sUserName)
        cmd.Parameters.Append cmd.CreateParameter("@PAYE_ref_no", adDouble, adParamInput, , CDbl(Val(nPAYERefNo)))
        cmd.Parameters.Append cmd.CreateParameter("@comp_alloc_number", adDouble, adParamInput, , CDbl(Val(nComID)))
'    End If
    
    Set rsRecordSet = cmd.Execute
    
    Set rsRecordSet.ActiveConnection = Nothing
    
    Set GetEmpIDRS = rsRecordSet
    
PROC_EXIT:
  
    cnConnection.Close
    Set cnConnection = Nothing
    
  Exit Function
  
PROC_ERROR:
  Err.Raise Err.Number, "GetEmpIDRS", _
            "The data could not be retrieved." & vbCrLf & _
            "Description: " & Err.Description
  GoTo PROC_EXIT

End Function
